#!/usr/bin/env python3

import sys

words = {}
for line in sys.stdin:
    key, value = line.strip().split("\t")
    if key not in words:
        words[key] = []
    words[key].append(value)

for key, value in words.items():
    print("{}\t{}".format(key, ','.join(value)))


